<template>
    <v-table
            :searchFlag="false"
            :hasEdit="false"
            :pageSize="pageSize"
            :page="page"
            :tableConfig="tableConfig"
            :tableData="tableData"
            :total="total"
            :pageFlag="false"
            @handleClickCell="handleClickCell"
            @findData="getTableData"
            @getTableData="getTableData"
            @upData="getTableData"
            @selectData="setSelectData"
            ref="table"
    ></v-table>
</template>

<script>
    import table from 'commons/Table'
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "Table",
        mixins: [baseMixin],
        props: {
            data: {
                type: Object
            }
        },
        data() {
            return {
                tableConfig: [
                    {
                        label: this.$t('config.shipper'),
                        prop: "storerkey",
                        input: "input",
                    },
                    {
                        label: this.$t('out.orderkey'),
                        prop: "orderkey",
                        input: "input",
                    },
                    {
                        label: this.$t('out.status'),
                        prop: "statusdescr",
                        input: "input",
                    },
                    {
                        label: this.$t('in.podate1'),
                        prop: "orderdate",
                        input: "date",
                    },
                    {
                        label: this.$t('config.carrier'),
                        prop: "carriername",
                        input: "input",
                    },
                    {
                        label: this.$t('config.num'),
                        prop: "totalqty",
                        input: "input",
                    },
                    {
                        label: this.$t('outbound.qtyallocated'),
                        prop: "totalallocated",
                        input: "input",
                    },
                    {
                        label: this.$t('outbound.qtypicked'),
                        prop: "totalpicked",
                        input: "input",
                    },
                  {
                    label:  this.$t('app.remark'),
                    prop: "remark",
                    input: "input",
                  },
                ],
                tableData: [],
              page: 1,
                pageSize: 10,
                total: 10,
                searhData: {}
            }
        },
        methods: {
          handleClickCell(data,config){
            if(config.prop == "orderkey"){
              this.$store.commit("setRouteData", data);
              this.$router.push({ name: 'ordersDeawer' });
            }
          },
            //获取table数据
            async getTableData(page, data) {
                try {
                    let res = await this.$api.get(`/queryOrderListByOrderkeyOfWavedetail1/${this.data.argument.wavekey}/1/999`);
                    
                        this.loading = false;
                        this.tableData = res.page.list;
                        //将订单数据传给发运方法
                        this.$parent.$parent.orderData = res.page.list;
                      this.page = res.page.curpage;
                        this.pageSize = res.page.pageSize;
                        this.total = res.page.total;
                    
                } catch (e) {
                    this.$message.error(e);
                }
            },
          //选中的数据
          setSelectData(data) {
            this.$parent.setSelectData(data)
          },
        },
        mounted() {
            this.getTableData(1, {})
        },
        components: {
            'v-table': table
        }
    }
</script>

<style scoped>

</style>
